package org.victoriest.server.util;

import java.util.Calendar;

import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.group.ChannelGroup;
import org.victoriest.server.event.VictoriestEvent;
import org.victoriest.server.protocol.Protocol;

public class MessageSender {

	public static void write(Channel e, Protocol type) {
		write(e, type, null);
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static void write(Channel e, Protocol type, Object message) {
		VictoriestEvent response = new VictoriestEvent();
		response.setType(type);
		response.setTimeStramp(Calendar.getInstance().getTimeInMillis());
		response.setSource(message);
		e.write(response);
	}
	
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static void write(ChannelGroup group, Protocol type, Object message){
		VictoriestEvent response = new VictoriestEvent();
		response.setType(type);
		response.setTimeStramp(Calendar.getInstance().getTimeInMillis());
		response.setSource(message);
		group.write(response);
	}
}
